#include <glib.h>

#define TEST_CASE_USER_DATA "my test data"

void test_case_func(void)
{
    return;
}

void test_case_func_with_data(gconstpointer user_data)
{
    g_assert_cmpstr((gchar *)user_data, ==, TEST_CASE_USER_DATA);
}

void _func_with_data_full_free_func(gpointer data)
{
    GList *l = (GList *)data;

    if(NULL != l) {

        if(NULL != l->data) {
            g_free(l->data);
        }

        g_free(l);
    }
}

void test_case_func_with_data_full(gconstpointer user_data)
{
    GList *l = (GList *)user_data;

    g_assert(l);

    g_assert_cmpstr((gchar *)l->data, ==, TEST_CASE_USER_DATA);
}

int main(int argc, char **argv)
{
    GList *l = NULL;

    l = g_new0(GList, 1);
    l->data = (gpointer)g_strdup(TEST_CASE_USER_DATA);

    g_test_init(&argc, &argv, NULL);

    g_test_add_func("/test/testcase", test_case_func);

    g_test_add_data_func("/test/func_with_data", (gconstpointer)TEST_CASE_USER_DATA, test_case_func_with_data);

    g_test_add_data_func_full("/test/func_with_data_full", (gpointer)l, test_case_func_with_data_full, _func_with_data_full_free_func);

    return g_test_run();
}

